<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>17canvas绘制扇形</title>
</head>
<style>
    canvas {
        border: 1px solid #ccc;
    }
</style>
<body>
<canvas width="600" height="400"></canvas>
<script>
    var myCanvas = document.querySelector('canvas');
    var ctx = myCanvas.getContext('2d');
    /*在中心位置画一个半径150px的右上角圆弧扇形*/
    var w =ctx.canvas.width;
    var h =ctx.canvas.height;
    /*把起点放到圆心位置*/
    ctx.moveTo(w/2,h/2);
    ctx.arc(w/2,h/2,150,3*Math.PI/2,0);
    /*闭合路径*/
    ctx.closePath();
    ctx.fill();

    ctx.stroke()
</script>
</body>
</html>
